﻿using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RollManager.Library.ActionSteps;
using RollManager.Library.ActionSteps.BaseClasses;
using RollManager.Library.Utils;

namespace RollManager.Tests.ActionSteps
{
    [TestClass]
    public class TestIISSiteSteps : TestBase
    {
        [TestMethod]
        public void IISSiteSetStepTests()
        {
            BreakIfDebugging();

            IISSiteSetStep step = new IISSiteSetStep();
            step.AlternateServer = "combizstage01";
            step.PropertyValue = "foo";

            // Test simple site property
            step.PropertyPath = "AnonymousUserName";
            step.WebSite = "MyCanvas";
            runStep( step, true );

            // Test simple root property
            step.PropertyPath = "AnonymousUserName";
            step.WebSite = string.Empty;
            runStep( step, true );

            // Test complex root property
            step.PropertyPath = "Filters/Compression/gzip/HcFileExtensions";
            step.WebSite = string.Empty;
            runStep( step, true );
        }

        [TestMethod]
        public void IISSiteGetStepTests()
        {
            BreakIfDebugging();

            IISSiteGetStep step = new IISSiteGetStep();
            step.AlternateServer = "combizstage01";

            // Test simple site property
            step.PropertyPath = "AnonymousUserName";
            step.WebSite = "MyCanvas";
            runStep( step, false );

            // Test simple root property
            step.PropertyPath = "AnonymousUserName";
            step.WebSite = string.Empty;
            runStep( step, false );

            // Test complex root property
            step.PropertyPath = "Filters/Compression/gzip/HcFileExtensions";
            step.WebSite = string.Empty;
            runStep( step, false );
        }

        private void runStep( ActionStep step, bool simulated )
        {
            step.RunStep( new ProgressReporter( null ), 0, new List<string>(), 
                simulated, new Dictionary<string, string>() );
        }
    }
}
